/***************************************************************************
 *   Copyright (C) 2011 by The rPem3d developers                           *
 *   elseifkk@users.sf.net                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "ori.h"
#include "config.h"

#include <qpushbutton.h>
#include <qradiobutton.h>

oriCls::~oriCls()
{
}
oriCls::oriCls ( QWidget *parent, const char *name )
		:oriDlg ( parent, name )
{
	orientation=IOP_UNKNOWN;
	unknownBut->setChecked ( true );
}

void oriCls::oriSlot()
{
	if ( SHTBut->isChecked() ) orientation=IOP_SHT;
	else if ( SHSBut->isChecked() ) orientation=IOP_SHS;
	else if ( SHCBut->isChecked() ) orientation=IOP_SHC;
	else if ( SFTBut->isChecked() ) orientation=IOP_SFT;
	else if ( SFSBut->isChecked() ) orientation=IOP_SFS;
	else if ( SFCBut->isChecked() ) orientation=IOP_SFC;
	else if ( PHTBut->isChecked() ) orientation=IOP_PHT;
	else if ( PHSBut->isChecked() ) orientation=IOP_PHS;
	else if ( PHCBut->isChecked() ) orientation=IOP_PHC;
	else if ( PFTBut->isChecked() ) orientation=IOP_PFT;
	else if ( PFSBut->isChecked() ) orientation=IOP_PFS;
	else if ( PFCBut->isChecked() ) orientation=IOP_PFC;
	else if ( DRHTBut->isChecked() ) orientation=IOP_DRHT;
	else if ( DRHSBut->isChecked() ) orientation=IOP_DRHS;
	else if ( DRHCBut->isChecked() ) orientation=IOP_DRHC;
	else if ( DRFTBut->isChecked() ) orientation=IOP_DRFT;
	else if ( DRFSBut->isChecked() ) orientation=IOP_DRFS;
	else if ( DRFCBut->isChecked() ) orientation=IOP_DRFC;
	else if ( DLHTBut->isChecked() ) orientation=IOP_DLHT;
	else if ( DLHSBut->isChecked() ) orientation=IOP_DLHS;
	else if ( DLHCBut->isChecked() ) orientation=IOP_DLHC;
	else if ( DLFTBut->isChecked() ) orientation=IOP_DLFT;
	else if ( DLFSBut->isChecked() ) orientation=IOP_DLFS;
	else if ( DLFCBut->isChecked() ) orientation=IOP_DLFC;
	else orientation=IOP_UNKNOWN;
	close();
}

QString oriCls::getImageOrientPat()
{
QString iopCode="";
  switch (orientation) {
     case IOP_SHT:  
     case IOP_PHT:  
     case IOP_DRHT: 
     case IOP_DLHT: 
     case IOP_SFT:  
     case IOP_PFT:  
     case IOP_DRFT: 
     case IOP_DLFT: 
	iopCode = "1\\0\\0\\0\\1\\0";
         break; 
     case IOP_SHS: 
     case IOP_PHS: 
     case IOP_DRHS:
     case IOP_DLHS:
     case IOP_SFS: 
     case IOP_PFS: 
     case IOP_DRFS:
     case IOP_DLFS:
	iopCode = "0\\1\\0\\0\\0\\-1";
         break;
     case IOP_SHC: 
     case IOP_PHC: 
     case IOP_DRHC:
     case IOP_DLHC:
     case IOP_SFC: 
     case IOP_PFC: 
     case IOP_DRFC:
     case IOP_DLFC:
	iopCode = "1\\0\\0\\0\\0\\-1";
	}

switch(orientation){
    case IOP_SHT:
	iopCode = "1\\0\\0\\0\\1\\0";
         break;
   case IOP_SHS:
	iopCode = "0\\1\\0\\0\\0\\-1";
         break;
   case IOP_SHC:
	iopCode = "1\\0\\0\\0\\0\\-1";
         break;
   case IOP_SFT:
	iopCode = "-1\\0\\0\\0\\1\\0";
         break;
   case IOP_SFS:
	iopCode = "0\\1\\0\\0\\0\\1";
         break;
   case IOP_SFC:
	iopCode = "-1\\0\\0\\0\\0\\1";
         break;
   case IOP_PHT:
	iopCode = "-1\\0\\0\\0\\-1\\0";
         break;
   case IOP_PHS:
	iopCode = "0\\-1\\0\\0\\0\\-1";
         break;
   case IOP_PHC:
	iopCode = "-1\\0\\0\\0\\0\\-1";
         break;
   case IOP_PFT:
	iopCode = "1\\0\\0\\0\\-1\\0";
         break;
   case IOP_PFS:
	iopCode = "0\\-1\\0\\0\\0\\1";
         break;
   case IOP_PFC:
	iopCode = "1\\0\\0\\0\\0\\1";
         break;
   case IOP_DRHT:
	iopCode = "1\\0\\0\\0\\1\\0";
         break;
   case IOP_DRHS:
   case IOP_DRHC:
   case IOP_DRFT:
   case IOP_DRFS:
   case IOP_DRFC:
   case IOP_DLHT:
   case IOP_DLHS:
   case IOP_DLHC:
   case IOP_DLFT:
   case IOP_DLFS:
   case IOP_DLFC:
	break;
  }
 return iopCode;
}
